﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>我的审核列表</title>

    <link href="~/Content/BootstrapSouce/css/bootstrap.css" rel="stylesheet" />
    <script src="~/Content/BootstrapSouce/js/jquery.min.js"></script>
    <script src="~/Content/BootstrapSouce/js/bootstrap.min.js"></script>


</head>
<body>
    
    <div id="data">
        <div class="col-md-12" style="margin-top:10px;height:35px;background-color:#0094ff">
            <form action="/Audit/AuditList" method="get">
                <table>
                    <tr>
                        <td>
                            <input name="pronum" type="text" placeholder="请输入报告编号查询" class="input-text" style="width:300px;" />
                            <input type="submit" style=" color:white;" value="查询" class="btn btn-primary" />
                        </td>


                    </tr>
                </table>
            </form>
        </div>
        

        <table class="table table-border table-bordered table-bg table-hover table-sort">
            <tr>
                <th>项目号</th>
                <th>勘查员</th>
                <th>估价员</th>
                <th>创建人</th>
                <th>房屋坐落</th>
                <th>建筑面积(m2)</th>
                <th>评估单价(元/m2)</th>
                <th>评估总值(元)</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            @{
                foreach (var item in Model)
                {
                    <tr>
                        <td>@item.projectNumber</td>
                        <td>@item.users_Name</td>
                        <td>@item.AuditSurvey</td>
                        <td>@item.AuditEvaluation</td>
                        <td>@item.house_Located</td>
                        <td>@item.basic_Acreage</td>
                        <td>@item.basic_UnitPrice</td>
                        <td>@item.basic_Total</td>
                        @switch ((int)item.basic_State)
                        {

                            case 3:
                                <td>
                                    评估完成
                                </td>
                                break;

                            case 5:
                            <td>
                                初审通过
                            </td>
                                break;

                            case 7:
                            <td>
                                终审通过
                            </td>
                                break;
                            default:
                            <td>已返回评估员</td>
                                break;

                        }


                        <td>
                            @if (item.basic_State == 3)
                            {

                                <input projectnumber="@item.projectNumber" basic_createtime="@item.basic_CreateTime" basic_id="@item.basic_id" basic_state="@item.basic_State" onclick="audit('初审',this)" style=" border-radius:5px; color:white;" class="btn btn-success" type="button" value="初审" data-toggle="modal" data-target="#modal_add_userUpts" />
                                
                            }
                            @if (item.basic_State == 5)
                            {
                                <input projectnumber="@item.projectNumber" basic_createtime="@item.basic_CreateTime" basic_id="@item.basic_id" basic_state="@item.basic_State" onclick="audit('终审',this)" style="background-color:#ed5151; border-radius:5px; color:white;" class="btn btn-success" type="button" value="终审" data-toggle="modal" data-target="#modal_add_userUpts" />
                            }


                        </td>
                    </tr>
                }
            }
        </table>

        <div class="modal fade" id="modal_add_userUpts" tabindex="-1" role="dialog" aria-labelledby="label_course">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                        <h4 class="modal-title" id="label_course"><strong>审核意见</strong></h4>
                    </div>
                    <div class="modal-body">
                        <table style="margin-top:20px;line-height:10px;" class="table table-striped">
                            <tr>
                                <td style="font-size:20px; width:150px;"><span style="color:red;">*</span>审核意见</td>
                                <td colspan="2"><input id="Auditing_Opinion" type="text" class="input-text" style="width:350px;" /></td>
                            </tr>

                        </table>
                        <input id="Button1" type="button" value="审核通过" onclick="updadd()" class="btn btn-success" style="background-color:#3c99e8; color:white;" />
                        <input id="Button2" type="button" value="审核不通过" onclick="noupd()" class="btn btn-success" style="background-color:#3c99e8; color:white;" />

                        <div class="modal-footer">
                            <button type="button" id="clos" class="btn btn-default" data-dismiss="modal">关闭</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</body>
</html>
<script>
    //shuaxin();
    //function shuaxin()
    //{
    //    $("#data").load("/Audit/AuditList", function () {});
    //}

    function audit(auditing_Type, obj) {
        $("#Auditing_Opinion").attr("basic_createtime", $(obj).attr("basic_createTime"));
        $("#Auditing_Opinion").attr("basic_State", $(obj).attr("basic_state"));
        $("#Auditing_Opinion").attr("basic_id", $(obj).attr("basic_id"));
        $("#Auditing_Opinion").attr("projectnumber", $(obj).attr("projectnumber"));
        $("#Auditing_Opinion").attr("auditing_Type", auditing_Type);
    }

    function updadd() {
        var Auditing_Opinion = $("#Auditing_Opinion").val();
        var basic_id = $("#Auditing_Opinion").attr("basic_id");
        var basic_State = $("#Auditing_Opinion").attr("basic_State");
        var basic_CreateTime = $("#Auditing_Opinion").attr("basic_CreateTime");
        var auditing_Type = $("#Auditing_Opinion").attr("auditing_Type");
        var projectNumber = $("#Auditing_Opinion").attr("projectNumber");
        $.ajax({
            type: "post",
            url: "http://localhost:63805/api/audit/" + localStorage.getItem("id"),
            data:
                {
                    Auditing_Opinion: Auditing_Opinion,
                    basic_id: basic_id,
                    basic_State: basic_State,
                    basic_CreateTime: basic_CreateTime,
                    auditing_Type: auditing_Type,

                    projectNumber: projectNumber

                },
            success: function (result) {
                if (result > 0) {
                    
                    alert("审核成功！！");
                    $("#modal_add_userUpts").modal('hide');
                   location.reload();
                    
                }
                else {
                    alert("审核失败！！");
                    $("#modal_add_userUpts").modal('hide');
                }
            }
        })
    }
    function noupd() {
        var basic_id = $("#Auditing_Opinion").attr("basic_id");
        var basic_State = $("#Auditing_Opinion").attr("basic_State");
        $.ajax({
            type: "get",
            url: "http://localhost:63805/apis/audit/putup?id=" + basic_id + "&state=" + basic_State,
            success: function (result) {
                if (result > 0) {
                    alert("审核不通过！");
                    location.reload();
                }else
                {
                    $("#modal_add_userUpts").modal('hide');
                }
            }
        })
    }
</script>
